package com.example.designpatterns.adapter;

import com.example.designpatterns.observer.WeatherDisplay;
import com.example.designpatterns.observer.WeatherStation;

/**
 * @author: Jovan
 * @date: 2025/5/8
 * @description:
 */
public class ObserverPatternDemo {
    public static void main(String[] args) {
        WeatherStation weatherStation = new WeatherStation();

        WeatherDisplay display1 = new WeatherDisplay("显示屏1", "℃");
        weatherStation.registerObserver(display1);

        WeatherDisplay display2 = new WeatherDisplay("显示屏2","°F");
        weatherStation.registerObserver(new FahrenheitObserverAdapter(display2));

        System.out.println("第一次温度更新...");
        // 显示屏2将看到77.9°F
        weatherStation.setTemperature(25.5f);

        System.out.println("\n第二次温度更新...");
        // 显示屏2将看到82.4°F
        weatherStation.setTemperature(28.0f);
    }
}
